package com.xayy.health.core.antlr4.enums;

import lombok.Getter;

/**
 * @author dongxingli
 * createTime 2020/9/28
 * @version V1.0
 */
public enum RuleResultEnum {

    SUCCESS(0, "成功"),

    EXPRESS_ERR(5001, "规则语法错误"),

    OUT_ERR(5002, "外部变量获取失败"),

    INTERNAL_ERR(5003, "内部变量获取失败"),

    FUNCTION_ERR(5004, "函数返回值错误"),

    UNEXPECT_PARAM(5005, "参数类型错误"),

    UNKNOWN_ERR(5006, "其他错误"),
    ;

    @Getter
    private int code;
    @Getter
    private String msg;


    RuleResultEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String matchMsg(int code) {
        RuleResultEnum[] values = RuleResultEnum.values();
        for (RuleResultEnum value : values) {
            if (value.getCode() == code) {
                return value.getMsg();
            }
        }
        return null;
    }
}
